<template>
  <div class="refine_dsupervise">
    <h2 class="titleblue">档案-基础数据</h2>
    <div class="contant">
      <div class="main">
        <div class="orgbtn fl">
          <label class="create bgblue">执法履职标准</label>
          <em></em>
        </div>
        <div class="listItem">
          <ul v-if="sos.length > 0">
            <li :class="index==level1?'activeli':''" v-for="(item,index) in sos" :key="index" class="itemli">
              <hr></hr>
              <div class="itemson" @click='actived(index, "level1")'>
                <em :class="index==level1||!item.subset?'el-icon-minus':'el-icon-plus'"
                    style="cursor: pointer;"></em>
                <span :class="index==level1?'active':''" style="cursor: pointer;">{{item.name}}</span>
              </div>
              <i class="el-icon-delete edit-icon" v-if='cuid==1' @click="delbtn(item)"
                 style="position:relative;z-index:3;cursor: pointer;margin-left:10px;"></i>
              <hr v-if="index==level1 && item.subset" style="width:200px"></hr>
              <div class="items" ref="ele" v-if='index==level1 && item.subset'>
                <ul>
                  <li v-for="(item1,index1) in item.subset" :key="index1"
                      :class='item.subset.length>2?"margin50":"margin25"' class="itemlison">
                    <hr class="fl width-30"></hr>
                    <div class="itemson" @click='actived(index1, "level2")'>
                      <em :class="index1==level2||!item1.subset?'el-icon-minus':'el-icon-plus'"
                          style="cursor: pointer;"></em>
                      <span :class="index1==level2?'active':''">{{item1.name}}</span>
                    </div>
                    <i class="el-icon-delete edit-icon" v-if='cuid==1' @click="delbtn(item1)"
                       style="position:relative;z-index:3;cursor: pointer;margin-left:10px;"></i>

                    <hr v-if="index1==level2 && item1.subset" style="width:200px"></hr>
                    <div class="items" ref="ele" style="width: 100%;" v-if='index1==level2 && item1.subset'>
                      <ul style="width: 100%;">
                        <li v-for="(item2,index2) in item1.subset" :key="index2"
                            :class='item1.subset.length>2?"margin50":"margin25"' class="itemlison"
                            style="z-index: 100;">
                          <hr class="fl width-30"></hr>
                          <div class="itemson">
                            <em class="el-icon-minus"></em>
                            <span id="ul1" class="active">{{item2.name}}</span>
                          </div>
                          <i class="el-icon-delete edit-icon" v-if='cuid==1' @click="delbtn(item2)"
                             style="position:relative;z-index:3;cursor: pointer;margin-left:10px;"></i>
                        </li>
                      </ul>
                    </div>

                  </li>
                </ul>
              </div>
            </li>
          </ul>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
  import taskTypeService from '@/services/TaskTypeService.js'

  export default {
    name: 'DocSupervise',
    data: function () {
      return {
        adddialog: false,
        sos: [],
        level1: -1,
        level2: -1,
        fheight: '1150px',
        distance: '',
        sysShow: false,
        ddid: '',
        cuid: 1,
        asdShow: true,
        aaa: false,
        detail: '',
        // cuid: localStorage.getItem('cu_id')
      }
    },
    created () {
      this.getData()
    },
    methods: {
      delbtn (item) {
        this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        })
          .then(() => {
            taskTypeService.delete(item.id).then(res => {
              this.$message({
                type: 'success',
                message: '删除成功'
              })
              // this.$emit('update')
              this.getData()
            })
          })
          .catch(() => {
            this.$message({
              type: 'info',
              message: '已取消删除'
            })
          })
      },
      actived1 (index) {
        this.level1 = index
        // this.fheight= this.$refs.ele[index].clientHeight+'px'
      },
      actived (index, key) {
          if (this[key] == index) {
              this[key] = -1
              return false
          }
          this[key] = index
          // this.fheight= this.$refs.ele[index].clientHeight+'px'
      },
      actived2 (index) {
        this.level2 = index
      },
      add () {
        this.adddialog = true
        this.$router.push('/index/emergency/sosOrganization/socreate')
        this.ddid = ''
        this.detail = 'create'
      },
      getData () {
        taskTypeService.search().then(res => {
          this.sos = res
          // res.forEach(item => {
          //   // if(!item.level)
          // })
        })
      },
      close () {
        this.adddialog = false
        this.getData()
        this.asdShow = false
      }
    }
  }
</script>

<style scoped lang="scss">
  .refine_dsupervise {
    width: 100%;
    display: inline-block;
    padding-bottom: 50px;
    min-height: 500px;

    .main {
      width: 100%;
      display: inline-block;
      position: relative;
      margin-top: 50px;
      padding-left: 50px;
      box-sizing: border-box;
    }

    .orgbtn {
      position: absolute;
      left: 50px;
      top: 50%;
      margin-top: -24px;
    }

    .orgbtn em {
      height: 1px;
      width: 30px;
      background: #aaa;
      margin-top: 19px;
      float: left;
      margin-left: -10px;
    }

    .orgbtn .bgblue {
      background: rgb(41, 139, 245)
    }

    .listItem {
      margin-left: 160px;
      position: relative;
    }

    .listItem ul {
      border-left: 1px solid #aaa;
    }

    .activeli {
      position: relative;
      z-index: 99;
    }

    .listItem li em {
      padding: 0px;
      font-size: 12px;
      margin-right: 10px;
      border: 1px solid #aaa;
      color: #333;
      float: left;
      margin-top: 6px;
    }

    .listItem li {
      margin-bottom: 10px;
    }

    .listItem li:first-child {
      transform: translateY(-50%);
      margin-bottom: 0px;
      margin-top: 0;
    }

    .listItem li:last-child {
      transform: translateY(46%);
      margin-top: -10px;
    }

    .listItem li:after {
      content: '';
      display: block;
      clear: both;
    }

    .listItem li hr {
      width: 30px;
      transform: translateY(-150%);
      margin-left: -1px;
      margin-top: 15px;
      float: left;
      position: relative;
      left: 0;
    }

    .listItem li span {
      float: left;
    }

    .listItem li .active {
      color: rgb(41, 139, 245);
    }

    .listItem li.active em {
      color: #ccc;
    }

    .itemson span {
      position: relative;
    }

    .itemson {
      float: left;
    }

    .items:after {
      content: '';
      display: block;
      clear: both;
    }

    .items {
      position: absolute;
      float: left;
      margin-top: 6px;
      left: 300px;
      top: -15px;
      background: #fff;
      z-index: 99;
      padding-top: 10px;
    }

    .edit-icon {
      float: left;
      margin-top: 5px;
    }

    .items li {
      position: relative;
      z-index: 99;
    }

    .items-cont {
      position: absolute;
      left: 314px;
      top: 0px;
      background: #fff;
      width: 300px;
      margin-left: -2px;
    }

    .items-cont li:first-child {
      transform: translateY(0%) !important;
      margin-bottom: 0px !important;
      top: -14px !important;
      position: relative;
      width: 300px;
    }

    .margin25:first-child {
      transform: translateY(0%) !important;
      top: -2px !important;

    }

    .margin25:first-child i {
      // margin-top:-3px;
    }

    .margin25:last-child {
      transform: translateY(0%) !important;
      margin-top: 0px !important;
      top: 11px;

    }

    .margin25:first-child .width-30 {
      margin-top: 3px;
      //    top: -3px !important;

    }

    .margin25:first-child .itemson {
      margin-top: -10px;
      // margin-left:30px;
    }

    .margin25:last-child .width-30 {
      margin-top: 6px;
      //     position: absolute;
      // left: 0;
      // float: left;
      // top: 10px;

    }

    .margin25:last-child .itemson {
      margin-top: -10px;
    }

    .margin25:last-child i {
      // margin-top:-3px;
    }

    .items-cont .margin50 {
      transform: translateY(85%) !important;
      margin-top: -50px !important;
    }

    .item-phone {
      position: relative;
      left: 55px;
    }

    .el-icon-phone-outline {
      margin-right: 5px;
    }

    .item-title {
      width: 100%;
      float: left;
    }

    .add-icon {
      font-size: 30px;
      cursor: pointer;
      margin-top: 10px;
    }

    .el-tabs .is-active:after {
      border-color: #fff
    }

    .edit-icon {
      float: left;
      margin-top: 5px;
    }
  }
</style>
